<?php
global $_POST;
require_once('./roots.php');
require_once('./classes/rbac.php');

$rbac=new rbac();

$gui=$rbac->Buscar_rol_usuario($_POST['name'],NULL,$_SESSION['sess_login_username']);

$rol=$_POST['name'];
	foreach ($gui as $key => $value) {

$aux=$rbac->Revocar_rol_usuario($rol,$value["id_user"],$_SESSION['sess_login_username']);
}

$gui1=$rbac->Buscar_permiso($_POST['name'],NULL,NULL,$_SESSION['sess_login_username']);


$user=$_POST['login_id'];
foreach ($gui1 as $key => $value) {

$aux1=$rbac->Revocar_permiso($value["id_role"],$value["id_resource"],$value["action"],$_SESSION['sess_login_username']);
}


$result=$rbac->Destruir_rol($_POST['name'], $_SESSION['sess_login_username']);

header("Location:RolListEliminar.php?result=".$result);

?>
